import commands, time, os

webcams = [
    { 'url': 'http://www.downeasthost.com/tblp/',
      'file': 'Camera1.jpg',
      'directory': 'tblp' },
    { 'url': 'http://icons.wunderground.com/webcamramdisk/d/o/Douga/1/',
      'file': 'current.jpg',
      'directory': 'ellsworth1'},
    { 'url': 'http://icons.wunderground.com/webcamramdisk/d/o/Douga/2/',
      'file': 'current.jpg',
      'directory': 'ellsworth2'},
    { 'url': 'http://icons.wunderground.com/webcamramdisk/b/a/bahabamaine/2/',
      'file': 'current.jpg',
      'directory': 'barharbor'}]

os.chdir('/home/dms/tblp')
imgs = '/var/www/imgs/'
imgs = '/mnt/usbdrive/imgs/'

def get_img(webcam):
    commands.getstatusoutput('wget '+webcam['url']+webcam['file'])
    commands.getstatusoutput('mv '+webcam['file']+' '+imgs+webcam['directory']+'/webcam.'+str(int(time.time()))+'.jpg')

    
while True:
    #commands.getstatusoutput('wget http://www.downeasthost.com/tblp/Camera1.jpg')
    #commands.getstatusoutput('mv Camera1.jpg /var/www/img/Camera1.'+str(int(time.time()))+'.jpg')
    for webcam in webcams:
        get_img(webcam)
    print str(int(time.time()))
    time.sleep(60*15)
